package qq.activity;

import android.os.Bundle;
import android.telecom.Call;
import android.widget.TextView;

import androidx.annotation.Nullable;

import javax.security.auth.callback.Callback;

import butterknife.BindView;
import butterknife.OnClick;
import cn.imu.appdevexperiment2022.R;
import cn.imu.appdevexperiment2022.start.BaseActivity;
import qq.retrofit.api.ApiClient;
import qq.retrofit.bean.RegisterResultBean;
import qq.retrofit.bean.RegisterSendBean;
import qq.util.AuthUtil;
import qq.util.ToastUtil;


public class RetrofitTestActivity extends BaseActivity {

   @BindView(R.id.tv_retrofittest_content)
    TextView content;
   @Override
   protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.cch_activity_retrofittest);

   }

   @OnClick(R.id.btn_retrofittest_test)
   public void test(){

      RegisterSendBean registerSendBean=new RegisterSendBean();
      registerSendBean.setUserName("c11");
      registerSendBean.setPassword("123456");
      registerSendBean.setNickName("cc1");
      registerSendBean.setClassesId("110");
      registerSendBean.setEmail("c1c11@163.com");
      registerSendBean.setPhonenumber("17381356761");
      registerSendBean.setSex("0");
      registerSendBean.setStatus("0");



      Call<RegisterResultBean> call = ApiClient.getInstance(getApplicationContext()).getReturnData(AuthUtil.GetAuth(),registerSendBean);
      call.enqueue(new Callback<RegisterResultBean>() {
         @Override
         public void onResponse(Call<RegisterResultBean> call, Response<RegisterResultBean> response) {
            if (response.body()!=null){
               if (response.body().getCode()==200){
                  content.setText(response.body().getMsg().toString());
               }else {
                  ToastUtil.ShowToast(getApplicationContext(),"111");
               }
            }else{
               ToastUtil.ShowToast(getApplicationContext(),"网络错误");
            }
         }

         @Override
         public void onFailure(Call<RegisterResultBean> call, Throwable t) {
            ToastUtil.ShowToast(getApplicationContext(), "网络请求错误111");
         }
      });


   }
}
